package io.zhengsh.vvip.leetcode.link;

import io.zhengsh.vvip.leetcode.ListNode;

public class Q82_Remove_Duplicates_From_Sotred_List_II {

    class Solution {
        public ListNode deleteDuplicates(ListNode head) {
            if (head == null) {
                return head;
            }
            ListNode dumy = new ListNode(0, head);
            ListNode cur = dumy;
            while (cur.next != null && cur.next.next != null) {
                if (cur.next.val == cur.next.next.val) {
                    int x = cur.next.val;
                    while (cur.next != null && cur.next.val == x) {
                        cur.next = cur.next.next;
                    }
                } else {
                    cur = cur.next;
                }
            }
            return dumy.next;
        }
    }
}
